#include "shadow.h"

void setShadow(QList<QWidget *> ws, int cid)
{
    if ((cid & InputType::Line) == InputType::Line)
    {
        QList<QLineEdit *> edits;
        foreach (QWidget * w, ws)
        {
            edits.append(w->findChildren<QLineEdit *>());
        }

        foreach (QWidget * edit, edits)
        {
            QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
            shadow->setColor(QColor(0,0,0,50));
            shadow->setOffset(1,1);
            shadow->setBlurRadius(8);
            edit->setGraphicsEffect(shadow);
        }
    }

    if ((cid & InputType::DateTime) == InputType::DateTime)
    {
        QList<QDateTimeEdit *> edits;
        foreach (QWidget * w, ws)
        {
            edits.append(w->findChildren<QDateTimeEdit *>());
        }

        foreach (QDateTimeEdit * edit, edits)
        {
            QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
            shadow->setColor(QColor(0,0,0,50));
            shadow->setOffset(1,1);
            shadow->setBlurRadius(8);
            edit->setGraphicsEffect(shadow);
        }
    }

    if ((cid & InputType::Combo) == InputType::Combo)
    {
        QList<QComboBox *> edits;
        foreach (QWidget * w, ws)
        {
            edits.append(w->findChildren<QComboBox *>());
        }

        foreach (QComboBox * edit, edits)
        {
            QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
            shadow->setColor(QColor(0,0,0,50));
            shadow->setOffset(1,1);
            shadow->setBlurRadius(8);
            edit->setGraphicsEffect(shadow);
        }
    }
}

void setShadow(QList<QWidget *> cws)
{
    foreach (QWidget * edit, cws)
    {
        QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
        shadow->setColor(QColor(0,0,0,50));
        shadow->setOffset(1,1);
        shadow->setBlurRadius(8);
        edit->setGraphicsEffect(shadow);
    }
}

void setShadow(QList<QWidget *> ws, int cid, QList<QWidget *> cws)
{
    setShadow(ws, cid);
    setShadow(cws);
}
